package org.yankun.exam4j.web.controller.dashboard;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.yankun.exam4j.core.exam.service.ExamService;
import org.yankun.exam4j.entity.UserExam;
import org.yankun.exam4j.session.SessionManager;
import org.yankun.exam4j.session.UserSessionData;


@Controller("DashboardController")
@RequestMapping("/dashboard")
public class DashboardController {
	
	@Resource
	private ExamService examService;
	
	@RequestMapping("index")
	public ModelAndView toIndex(HttpServletResponse response,HttpServletRequest request,String email,String password){
		Map<String, Object> map=new HashMap<String, Object>();
		
		HttpSession session = request.getSession();
		UserSessionData usd = SessionManager.getSessionData(session);
		
		List<UserExam> userExamList = examService.getUserExamByUserId(usd.getUserId());
		
		map.put("userExamList", userExamList);
		return new ModelAndView("/dashboard/index",map);
	}
	
}